#include<stdio.h>
#include<conio.h>
int n,m;
int RobotInstruction(int start,int number,int a[])
{
	int dem[number],i,tong;
	for (i=0;i<number;i++)
	{
		if (a[i]==108) 
		dem[i]=-1;
		else
		{
			if (a[i]==114) 
		    dem[i]=1;
		    else 
		    {
		    	dem[i]=dem[a[i]-1];
		    }
		}
	}
	//tong cac buoc di 
	for (i=0;i<number;i++)
	{
		n+=dem[i];
	}
	tong=n;
	n=0;
	return tong;
}
main(){
	int a[3]={'l','r',2},b[5]={'l',1,2,1,4};
	n=0;
	printf("%d\n",RobotInstruction(n,3,a));
	printf("%d\n",RobotInstruction(n,5,b));
	getch();
}
